package com.bocai.yuweiwangluo.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bocai.yuweiwangluo.R;
import com.bocai.yuweiwangluo.activity.HomeBannerActivity;
import com.bocai.yuweiwangluo.base.BaseFragment;
import com.bocai.yuweiwangluo.bean.HomeBean;
import com.bocai.yuweiwangluo.utils.ImageLoaderUtil;
import com.bocai.yuweiwangluo.utils.UrlData;

import butterknife.ButterKnife;


/**
 * Created by admin on 2015/9/16.
 */
public class BannerFrag extends BaseFragment{
    private View view;
    private ImageView iv_banner;
    private HomeBean.Banner data;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.banner_grag, container, false);
        initView();
        return view;
    }
    public void getData(HomeBean.Banner data){
        this.data=data;


    }

    private void initData() {
        try{
            ImageLoaderUtil.loaderImageDefault(UrlData.IMAGEURL + data.getPic(), iv_banner);
        }catch (Exception e){}


    }

    private void initView() {
        ButterKnife.bind(this, view);
        iv_banner=(ImageView)view.findViewById(R.id.iv_banner);
        initData();
        iv_banner.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(), HomeBannerActivity.class);
                intent.putExtra("url",data.getUrl());
                startActivity(intent);
            }
        });
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
